---
image: /generated/articles-docs-webcodecs-webcodecs-controller.png
id: webcodecs-controller
title: webcodecsController()
slug: /webcodecs/webcodecs-controller
crumb: '@remotion/webcodecs'
---

:::warning
[We are phasing out Remotion WebCodecs and are moving to Mediabunny](/blog/mediabunny)!
:::

Pass `webcodecsController()` to [`controller`](/docs/webcodecs/convert-media#controller) to steer the `convertMedia()` function.

```tsx twoslash title="Use webcodecsController()"
import {webcodecsController, convertMedia} from '@remotion/webcodecs';

const controller = webcodecsController();

convertMedia({
  src: 'https://www.w3schools.com/html/mov_bbb.mp4',
  container: 'webm',
  controller,
});

// Pause
controller.pause();

// Resume
controller.resume();

// Abort
controller.abort();
```

## API

This function returns an object that can be passed to [`convertMedia({controller})`](/docs/webcodecs/convert-media#controller).

It has the following methods:

### `pause()`

Pauses the conversion.

### `resume()`

Resumes the conversion.

### `abort()`

Aborts the conversion.

### `addEventListener()`

See events below.

### `removeEventListener()`

See events below.

## Events

You can attach event listeners to the `webcodecsController` object.

```tsx twoslash title="Use events"
import {webcodecsController, convertMedia} from '@remotion/webcodecs';

const controller = webcodecsController();

const onPause = () => {
  console.log('Paused');
};

const onResume = () => {
  console.log('Resumed');
};

controller.addEventListener('pause', onPause);
controller.addEventListener('resume', onResume);

// Make sure to cleanup later:
controller.removeEventListener('pause', onPause);
controller.removeEventListener('resume', onResume);
```

The `webcodecsController` object emits the following events:

### `pause`

Emitted when the conversion is paused.

### `resume`

Emitted when the conversion is resumed.

## See also

- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/webcodecs/src/webcodecs-controller.ts)
- [Pause, resume and abort conversion](/docs/webcodecs/pause-resume-abort)
- [`convertMedia()`](/docs/webcodecs/convert-media)
